﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace Iworld.Toolkit.Converter
{
    public class BoolToDisplayStringConverter : ConverterBase<bool?, string>
    {
        
        public string Format { set; get; }

        public BoolToDisplayStringConverter()
        {
            Format = "是,否";
        }

        protected override string ConvertNotNull(bool? value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
             string fm = Format;
             if (parameter != null) fm = parameter.ToString();
             string[] attr = fm.Split(new char[]{','});
             if (attr.Length < 2) throw new Exception("格式错误");
             if(value == true)
             {
                 return attr[0];
             }else
             {
                 return attr[1];
             }
        }

        protected override bool? ConvertBackNotNull(string value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
}
